package algorithmTopics.mathematics;

import java.util.*;

public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //读取种类总数
        int n = sc.nextInt();
        sc.nextLine();
        // 读取不同类型
        String[] miString = sc.nextLine().split(" ");
        String[] xiString = sc.nextLine().split(" ");
        sc.close();
        //转化为int 类型
        int[] mi = new int[xiString.length];
        int[] xi = new int[xiString.length];
        for (int i = 0; i < xiString.length; i++) {
            mi[i] = Integer.parseInt(miString[i]);
            xi[i] = Integer.parseInt(xiString[i]);
        }

        // 存放不同钟可以称的数量数
        Set<Integer> res = new HashSet<>();
        res.add(0);
        //循环每一种
        for (int i = 0; i < n; i++) {
            //循环每一种中的数量
            for(int j = 0; j < xi[i]; j++){
                List<Integer> tempList = new ArrayList<>(res);
                List<Integer> newElements = new ArrayList<>();
                for(int num : tempList){
                    newElements.add(num + mi[i]);
                }
                res.addAll(newElements);
            }
        }


        System.out.println(res.size());

    }

   


}